home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomctl.ocx"
- Begin VB.Form frmConfigure
- BorderStyle = 3 'Fixed Dialog
- Caption = "Configure Service"
- ClientHeight = 4050
- ClientLeft = 45
- ClientTop = 330
- ClientWidth = 3585
- Icon = "frmConfigure.frx":0000
- LinkTopic = "Form1"
- MaxButton = 0 'False
- MinButton = 0 'False
- ScaleHeight = 4050
- ScaleWidth = 3585
- ShowInTaskbar = 0 'False
- StartUpPosition = 1 'CenterOwner
- Begin MSComctlLib.ListView listDependencies
- Height = 975
- Left = 1320
- TabIndex = 11
- Top = 2520
- Width = 2175
- _ExtentX = 3836
- _ExtentY = 1720
- View = 3
- LabelEdit = 1
- Sorted = -1 'True
- LabelWrap = -1 'True
- HideSelection = -1 'True
- HideColumnHeaders= -1 'True
- Checkboxes = -1 'True
- _Version = 393217
- ForeColor = -2147483640
- BackColor = -2147483643
- BorderStyle = 1
- Appearance = 1
- NumItems = 1
- BeginProperty ColumnHeader(1) {BDD1F052-858B-11D1-B16A-00C0F0283628}
- Object.Width = 3087
- EndProperty
- End
- Begin VB.CommandButton cmdOK
- Caption = "OK"
- Default = -1 'True
- Height = 375
- Left = 1200
- TabIndex = 12
- Top = 3600
- Width = 1095
- End
- Begin VB.CommandButton cmdCancel
- Cancel = -1 'True
- Caption = "Cancel"
- Height = 375
- Left = 2400
- TabIndex = 13
- Top = 3600
- Width = 1095
- End
- Begin VB.ComboBox cboErrorControl
- Height = 315
- ItemData = "frmConfigure.frx":000C
- Left = 1320
- List = "frmConfigure.frx":001C
- Style = 2 'Dropdown List
- TabIndex = 9
- Top = 2040
- Width = 2175
- End
- Begin VB.ComboBox cboServiceType
- Height = 315
- ItemData = "frmConfigure.frx":0042
- Left = 1320
- List = "frmConfigure.frx":0052
- Style = 2 'Dropdown List
- TabIndex = 7
- Top = 1560
- Width = 2175
- End
- Begin VB.TextBox txtFileName
- Height = 285
- Left = 1320
- TabIndex = 5
- Top = 1080
- Width = 2175
- End
- Begin VB.TextBox txtDisplayName
- Height = 285
- Left = 1320
- TabIndex = 3
- Top = 600
- Width = 2175
- End
- Begin VB.TextBox txtServiceName
- Height = 285
- Left = 1320
- TabIndex = 1
- Top = 120
- Width = 2175
- End
- Begin VB.Label Label6
- Caption = "De&pendencies:"
- Height = 255
- Left = 120
- TabIndex = 10
- Top = 2520
- Width = 1215
- End
- Begin VB.Label Label5
- Caption = "Error &Control:"
- Height = 255
- Left = 120
- TabIndex = 8
- Top = 2040
- Width = 1095
- End
- Begin VB.Label Label4
- Caption = "Service &Type:"
- Height = 255
- Left = 120
- TabIndex = 6
- Top = 1560
- Width = 1215
- End
- Begin VB.Label Label3
- Caption = "&File Name:"
- Height = 255
- Left = 120
- TabIndex = 4
- Top = 1080
- Width = 1215
- End
- Begin VB.Label Label2
- Caption = "&Display Name:"
- Height = 255
- Left = 120
- TabIndex = 2
- Top = 600
- Width = 1215
- End
- Begin VB.Label Label1
- Caption = "&Service Name:"
- Height = 255
- Left = 120
- TabIndex = 0
- Top = 120
- Width = 1095
- End
- Attribute VB_Name = "frmConfigure"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- '****************************************************************************************************
- ' Copyright (c) Key Technology Pty Ltd 1999, All Rights Reserved.
- ' Web site: http://www.keytech.com.au Email: info@keytech.com.au
- '****************************************************************************************************
- Option Explicit
- Private mServiceName As String
- Private mConfigurationChanged As Boolean
- Private Sub FillDependenciesListView()
- On Error GoTo ErrorHandler
- ' Clear the list view
- listDependencies.ListItems.Clear
- ' Open the service manager
- Dim ServiceManager As New ServiceManager
- ServiceManager.ComputerName = frmMain.ComputerName
- ' Check if any services!
- Dim v As Variant
- v = ServiceManager.Services
- If VarType(v) <> (vbString Or vbArray) Then Exit Sub
- ' Display the service names
- Dim ServiceName() As String
- Dim i As Integer
- Dim ListItem As ListItem
- Dim Text As String
- ServiceName = v
- For i = LBound(ServiceName) To UBound(ServiceName)
- ' Exclude the service being configured
- If ServiceName(i) <> mServiceName Then
- ' Service display name
- Dim DisplayName As String
-
- DisplayName = ServiceManager.DisplayName(ServiceName(i))
-
- Set ListItem = listDependencies.ListItems.Add(, ServiceName(i), DisplayName)
- End If
- Next
- Exit Sub
- ErrorHandler:
- MsgBox Err.Description, vbExclamation
- End Sub
- Private Sub SetDependenciesStatus()
- On Error GoTo ErrorHandler
- ' Get the configuration object for the selected service
- Dim ServiceManager As New ServiceManager
- Dim ServiceConfiguration As ServiceConfiguration
- ServiceManager.ComputerName = frmMain.ComputerName
- Set ServiceConfiguration = ServiceManager.Configuration(mServiceName)
-
- ' Display dependencies
- Dim v As Variant
- Dim i As Integer
- Dim DependencyName() As String
- Dim DependencyCount As Long
- Dim ListItem As ListItem
- v = ServiceConfiguration.Dependencies
- If VarType(v) <> (vbString Or vbArray) Then Exit Sub
- DependencyName = v
- DependencyCount = UBound(DependencyName) - LBound(DependencyName) + 1
- For i = LBound(DependencyName) To UBound(DependencyName)
- On Error Resume Next
- Set ListItem = listDependencies.ListItems(DependencyName(i))
- On Error GoTo 0
-
- If Not ListItem Is Nothing Then ListItem.Checked = True
- Next
- Exit Sub
- ErrorHandler:
- MsgBox Err.Description, vbExclamation
- End Sub
- Private Sub cmdCancel_Click()
- Unload Me
- End Sub
- Private Sub cmdOK_Click()
- On Error GoTo ErrorHandler
- Dim ServiceManager As New ServiceManager
- ServiceManager.ComputerName = frmMain.ComputerName
- ServiceManager.AccessMode = WriteAccess
- ' If a new service, create it
- If Len(mServiceName) = 0 Then
- ServiceManager.Create txtServiceName, txtDisplayName, txtFileName
- mServiceName = txtServiceName
- End If
- ' Get the configuration object for the selected service
- Dim ServiceConfiguration As ServiceConfiguration
- Set ServiceConfiguration = ServiceManager.Configuration(mServiceName)
- ' Set the display name
- ServiceConfiguration.DisplayName = txtDisplayName
- ' Set the file name
- ServiceConfiguration.FileName = txtFileName
- ' Set the service type
- Dim ServiceType As ServiceType
- Select Case cboServiceType.ListIndex
- Case 0
- ServiceType = Win32OwnProcess
-
- Case 1
- ServiceType = Win32OwnProcess Or InteractiveProcess
-
- Case 2
- ServiceType = Win32ShareProcess
-
- Case 3
- ServiceType = Win32ShareProcess Or InteractiveProcess
- End Select
- ServiceConfiguration.ServiceType = ServiceType
- ' Set the error control
- Dim ErrorControl As ErrorControl
- Select Case cboErrorControl.ListIndex
- Case 0
- ErrorControl = Ignore
-
- Case 1
- ErrorControl = Normal
-
- Case 2
- ErrorControl = Severe
-
- Case 3
- ErrorControl = Critical
- End Select
- ServiceConfiguration.ErrorControl = ErrorControl
- ' Set the dependencies
- Dim v As Variant
- Dim DependencyName() As String
- Dim DependencyCount As Long
- Dim ListItem As ListItem
- For Each ListItem In listDependencies.ListItems
- If ListItem.Checked Then
- DependencyCount = DependencyCount + 1
- ReDim Preserve DependencyName(1 To DependencyCount) As String
- DependencyName(DependencyCount) = ListItem.Key
- End If
- Next
- If DependencyCount Then v = DependencyName
- ServiceConfiguration.Dependencies = v
- mConfigurationChanged = True
- Unload Me
- Exit Sub
- ErrorHandler:
- MsgBox Err.Description, vbExclamation
- End Sub
- Private Sub Form_Load()
- On Error GoTo ErrorHandler
- ' Display service name
- txtServiceName = mServiceName
- ' Fill the dependencies list view
- FillDependenciesListView
- ' If creating a service nothing more to display
- If Len(mServiceName) = 0 Then
- Caption = "Create Service"
- cboServiceType.ListIndex = 0
- cboErrorControl.ListIndex = 1
- Exit Sub
- End If
- Caption = "Configure Service"
- txtServiceName.Locked = True
- ' Get the configuration object for the selected service
- Dim ServiceManager As New ServiceManager
- Dim ServiceConfiguration As ServiceConfiguration
- ServiceManager.ComputerName = frmMain.ComputerName
- Set ServiceConfiguration = ServiceManager.Configuration(mServiceName)
- ' Display display name
- txtDisplayName = ServiceConfiguration.DisplayName
- ' Display file name
- txtFileName = ServiceConfiguration.FileName
- ' Display service type
- Select Case ServiceConfiguration.ServiceType
- Case Win32OwnProcess
- cboServiceType.ListIndex = 0
-
- Case Win32OwnProcess Or InteractiveProcess
- cboServiceType.ListIndex = 1
-
- Case Win32ShareProcess
- cboServiceType.ListIndex = 2
-
- Case Win32ShareProcess Or InteractiveProcess
- cboServiceType.ListIndex = 3
-
- Case Else
- cboServiceType.ListIndex = 0
- End Select
- ' Display error control
- Select Case ServiceConfiguration.ErrorControl
- Case Ignore
- cboErrorControl.ListIndex = 0
-
- Case Normal
- cboErrorControl.ListIndex = 1
-
- Case Severe
- cboErrorControl.ListIndex = 2
-
- Case Critical
- cboErrorControl.ListIndex = 3
-
- Case Else
- cboErrorControl.ListIndex = 0
- End Select
- ' Display dependencies
- SetDependenciesStatus
- Exit Sub
- ErrorHandler:
- MsgBox Err.Description, vbExclamation
- End Sub
- Public Property Let ServiceName(ByVal NewValue As String)
- mServiceName = NewValue
- End Property
- Public Property Get ConfigurationChanged() As Boolean
- ConfigurationChanged = mConfigurationChanged
- End Property
-